﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using RearLivestock.Common.Domains.hhx;
using RearLivestock.Common.Domains.hq;
using RearLivestock.Common.Domains.wbx;
using RearLivestock.Common.Domains.zjy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RearLivestock.Common.DBContexts
{
    /// <summary>
    /// 数据库上下文
    /// </summary>
    public class EFDBContext : DbContext
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="options"></param>
        public EFDBContext(DbContextOptions<EFDBContext> options) : base(options)
        {
        }

        #region hhx
        /// <summary>
        /// 用户信息表
        /// </summary>
        public DbSet<Users> Users { get; set; }
        /// <summary>
        /// 证件类型表
        /// </summary>
        public DbSet<IDCards> IDCards { get; set; }
        /// <summary>
        /// 学历表
        /// </summary>
        public DbSet<Studies> Studies { get; set; }
        /// <summary>
        /// 单位表
        /// </summary>
        public DbSet<Units> Units { get; set; }
        /// <summary>
        /// 员工状态表
        /// </summary>
        public DbSet<Employees> Employees { get; set; }
        /// <summary>
        /// 部门表
        /// </summary>
        public DbSet<Epartments> Epartments { get; set; }
        /// <summary>
        /// 公猪初期表
        /// </summary>
        public DbSet<Infancies> Infancies { get; set; }
        /// <summary>
        /// 母猪分娩
        /// </summary>
        public DbSet<Farrowings> Farrowings { get; set; }
        /// <summary>
        /// 分娩难易表
        /// </summary>
        public DbSet<Difficulties> Difficulties { get; set; }
        /// <summary>
        /// 肥猪批次
        /// </summary>
        public DbSet<Batchs> Batchs { get; set; }
        /// <summary>
        /// 母性
        /// </summary>
        public DbSet<Maternals> Maternals { get; set; }
        /// <summary>
        /// 转舍类型
        /// </summary>
        public DbSet<ChangeHouseTypes> ChangeHouseTypes { get; set; }
        /// <summary>
        /// 猪只转舍
        /// </summary>
        public DbSet<ChangeHouses> ChangeHouses { get; set; }
        /// <summary>
        /// 后裔转种
        /// </summary>
        public DbSet<ScionChanges> ScionChanges { get; set; }
        /// <summary>
        /// 死亡原因
        /// </summary>
        public DbSet<DeathReasons> DeathReasons { get; set; }
        /// <summary>
        /// 猪只死亡
        /// </summary>
        public DbSet<PigDeaths> PigDeaths { get; set; }
        /// <summary>
        /// 品相测定
        /// </summary>
        public DbSet<Conditions> Conditions { get; set; }
        #endregion

        #region wbx

        /// <summary>
        /// 角色信息表
        /// </summary>
        public DbSet<Roles> Roles { get; set; }
        /// <summary>
        /// 品种信息表
        /// </summary>
        public DbSet<Varieties> Varieties { get; set; }
        /// <summary>
        /// 基本信息表
        /// </summary>
        public DbSet<BasicInformation> BasicInformations { get; set; }
        /// <summary>
        /// 猪只类型
        /// </summary>
        public DbSet<PigType> PigTypes { get; set; }

        /// <summary>
        /// 配种方式
        /// </summary>
        public DbSet<Breedingmethod> Breedingmethods { get; set; }
        /// <summary>
        /// 种猪配种
        /// </summary>
        public DbSet<PigsBreeding> PigsBreedings { get; set; }
        /// <summary>
        /// 种猪历史
        /// </summary>
        public DbSet<PigHistory> PigHistorys { get; set; }
        /// <summary>
        /// 仔猪断奶
        /// </summary>
        public DbSet<PigletsWeaning> PigletsWeanings { get; set; }
        /// <summary>
        /// 猪只体重
        /// </summary>
        public DbSet<PigsWeighing> PigsWeighings { get; set; }
        /// <summary>
        /// 称重类型
        /// </summary>
        public DbSet<WeighingType> WeighingTypes { get; set; }

        #endregion

        #region hq

        /// <summary>
        /// 企业表
        /// </summary>
        public DbSet<Enterprise> Enterprise { get; set; }

        /// <summary>
        /// 栋舍管理
        /// </summary>
        public DbSet<Bedrooms> Bedrooms { get; set; }

        /// <summary>
        /// 栋舍类型表
        /// </summary>
        public DbSet<BedroomTypes> BedroomTypes { get; set; }

        /// <summary>
        /// 栏位
        /// </summary>
        public DbSet<Fields> Fields { get; set; }

        /// <summary>
        /// 部门管理
        /// </summary>
        public DbSet<Departments> Departments { get; set; }

        /// <summary>
        /// 部门类型
        /// </summary>
        public DbSet<DepartmentType> DepartmentType { get; set; }

        /// <summary>
        /// 部门区域
        /// </summary>
        public DbSet<DepartmentAreas> DepartmentAreas { get; set; }

        /// <summary>
        /// 后裔期初
        /// </summary>
        public DbSet<PigBabys> PigBabys { get; set; }
        /// <summary>
        /// 体侧
        /// </summary>
        public DbSet<Heights> Heights { get; set; }
        /// <summary>
        /// 猪场管理
        /// </summary>
        public DbSet<Pigfarmas> Pigfarmas { get; set; }
        /// <summary>
        /// 母猪断奶
        /// </summary>
        public DbSet<Ablactations> Ablactations { get; set; }
        /// <summary>
        /// 猪只淘汰
        /// </summary>
        public DbSet<Eliminates> Eliminates { get; set;}
        /// <summary>
        /// 销售添加
        /// </summary>
        public DbSet<Sales> Sales { get; set; }
        /// <summary>
        /// 客户添加
        /// </summary>
        public DbSet<Clients> Clients { get; set; }


        #endregion

        #region zjy

        /// <summary>
        /// 角色表
        /// </summary>
        public DbSet<Permissions> Permissions { get; set; }

        /// <summary>
        /// 角色权限表
        /// </summary>
        public DbSet<RolePermissions> RolePermissions { get; set; }

        /// <summary>
        /// 种母期初
        /// </summary>
        public DbSet<BreedingSows> BreedingSows { get; set; }

        /// <summary>
        /// 妊检方式
        /// </summary>
        public DbSet<PregnancyTestType> PregnancyTestTypes { get; set; }

        /// <summary>
        /// 妊检结果
        /// </summary>
        public DbSet<PregnancyTestResults> PregnancyTestResults { get; set; }

        /// <summary>
        /// 种母妊检
        /// </summary>
        public DbSet<PrenatalCheckups> PrenatalCheckups { get; set; }

        #endregion

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //           modelBuilder
            //               .Entity<Farrowings>()
            //               .Property(e => e.Gender)
            //               .HasColumnType("bit(1)")
            //.HasDefaultValueSql("'b\\'1\\''");

            //var converter = new BoolToZeroOneConverter<int>();

            //modelBuilder
            //    .Entity<Farrowings>()
            //    .Property(e => e.Gender)
            //    .HasColumnType("bit(1)")
            //     .HasConversion<bool>();
        }
    }
}
